<?php

/**
 * Admin
 *
 * Description: Class for User Management Module
 *
 * PHP Version: 1.2.3
 *
 * @author Johari <joharijumali@gmail.com>
 */

/**
 * Admin
 *
 * Description: Class for User Management Module
 *
 * @author Johari <joharijumali@gmail.com>
 */

class Console_User_Controller extends Base_Controller
{

    public $restful = true;

	/**
     * Function get_index
	 *
	 * @return get_index.
     */
    public function get_index()
	{
        return Redirect::to('admin/user/userlist');
    }
	
	/**
     * Function post_resetpassword
	 *
	 * @return post_resetpassword.
     */
    public function post_resetpassword()
	{
        $input = Input::all();

        $user = Console_User::find(Auth::user()->userid);

        if (Hash::check($input['oldpassword'], $user->password) && $input['password'] == $input['repassword']) {
            if (isset($input['username']) && $input['username'] != null) {
                $user->username = $input['username'];
            }
            $user->password = Hash::make($input['password']);
            $user->save();
        }
    }
	
	/**
     * Function get_profile
	 *
	 * @return get_profile.
     */
    public function get_profile()
    {
        $profile = Console_Profile::loggedprofile();

        return $profile;
    }

	/**
     * Function post_profile
	 *
	 * @return post_profile.
     */
    public function post_profile()
    {
        $input = Input::all();

        $profile = Console_Profile::find(Auth::user()->userid);
        $profile->fullname = $input['fullname'];
        $profile->emel = $input['emel'];
        $profile->icno = $input['icno'];

        $profile->save();

        $profile = Console_Profile::loggedprofile();

        return $profile;
    }

}

?>